package com.ykq.controller;

import com.ykq.entity.Branch;
import com.ykq.entity.Staff;
import com.ykq.service.BranchService;
import com.ykq.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @program: keyboard
 * @description:
 * @author: 闫克起2
 * @create: 2023-07-22 15:00
 **/
@RestController
@RequestMapping("/branch")
public class BranchController {

    @Autowired
    private BranchService branchService;

    @GetMapping("/listById")
    public Result listById(HttpSession session){
        //从会话中获取当前用户信息
        Staff staff = (Staff) session.getAttribute("staff");
        //获取当前用户所在的门店id
        Integer branchid = staff.getBranchid();
        //如果门店为总店且为店长
        if(staff.getRoleid()==1&&staff.getBranchid()==12138){
            branchid=null;
        }
        List<Branch> list = branchService.findById(branchid);
        return new Result(200,"查询店铺成功",list);
    }
}












